package com.qimo.zzy.controller;

import com.qimo.zzy.service.CollectionService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@CrossOrigin//跨域
@RestController//遵循RestFul
@RequestMapping("/qimo/Collection/")
public class CollectionController {
    @Resource
    CollectionService collectionService;

    /**
     * 查询所有收藏接口
     *
     * @param uid
     * @return
     */
    @GetMapping("getAllCollection")
    private String getAllCollection(@RequestParam("uid") int uid) {
        return collectionService.getAllCollection(uid);
    }

    /**
     * 删除当前收藏
     *
     * @param uid
     * @param pid
     * @return
     */
    @DeleteMapping("deleteCollection")
    private String deleteCollection(
            @RequestParam("uid") int uid,
            @RequestParam("pid") int pid
    ) {
        return collectionService.deleteCollection(uid, pid);
    }

    @PostMapping("creatCollection")
    private String creatCollection(
            @RequestParam("uid") int uid,
            @RequestParam("pid") int pid
    ) {
        return collectionService.creatCollection(uid, pid);
    }

}
